<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ace="http://www.icefaces.org/icefaces/components"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
  <h:head>
  </h:head>

  <h:body>
    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                    xmlns:h="http://java.sun.com/jsf/html"
                    xmlns:f="http://java.sun.com/jsf/core"
                    xmlns:c="http://java.sun.com/jsp/jstl/core"
                    xmlns:ace="http://www.icefaces.org/icefaces/components"
                    xmlns:icecore="http://www.icefaces.org/icefaces/core"
                    xmlns:ui="http://java.sun.com/jsf/facelets"
                    template="layout.xhtml">
      <ui:define name="title">My Profile / Awesome Dates</ui:define>
      <ui:define name="content">

        <ace:messages globalOnly="true"/>
        <ace:panel  header="#{userManager.user.username}" >
          <div>
            <div class="profileImgContainer">
              <h:graphicImage class="profilePic" 
                              value="images/userPictures/#{userManager.user.username}/#{userManager.user.profilePicture}" alt="Profile picture"></h:graphicImage>
            </div>
            <div class="userInfos">
              <h:form> 
                <h:commandButton value="Update your profile" action="updateProfile.xhtml"/>
                <h:commandButton value="My favorite" rendered="#{userManager.user.isPrivileged}" action="favorite.xhtml"/>
              </h:form>
              <span>Sex: #{userManager.user.sex}</span><br/>
              <span>Looking for: #{userManager.user.lookingForSex}</span><br/>
              <span>Age: #{userManager.user.age}</span>
              <span>Height: #{userManager.user.height} cm</span><br/>
              <span>City: #{userManager.user.city}</span><br/>
            </div>
            <div id="uploadProfilePicDiv">
              <button id="profilePicSpan">Change profile pic</button>
              <h:form id="uploadProfilePic">
                <ace:fileEntry id="file-entry"

                               fileEntryListener="#{userManager.user.changeProfilePic}"
                               maxFileSize="6291456"
                               maxFileSizeMessage="Submitted file is too large."
                               maxTotalSize="18874368"
                               maxTotalSizeMessage="Total size of submitted files is too large."
                               required="true"
                               requiredMessage="The file is required to submit this form."
                               useOriginalFilename="true"
                               absolutePath="/awesome-dates/userPictures/temp/"
                               autoUpload="true"
                               multiple="false"
                               />
                <ace:messages id="msgs" for="uploadProfilePic:file-entry"/>
              </h:form>

            </div>
          </div>
          <ace:panel header="Goal">
            #{userManager.user.goal}
          </ace:panel>
          <ace:panel header="Resume">
            #{userManager.user.resume}
          </ace:panel>

          <ace:panel header="Appearance">
            #{userManager.user.apparence}
          </ace:panel>
          <ace:panel header="Pictures">
            <ui:repeat value="#{userManager.user.pictures}" var="p">
              <div class="profileImgContainer">
                <h:graphicImage class="profilePic" 
                                value="images/userPictures/#{userManager.user.username}/#{p}" alt="User picture"></h:graphicImage>
              </div>
            </ui:repeat>
          </ace:panel>
          <ace:panel>
            <h:form id="uploadForm">
              <ace:fileEntry id="file-entry"
                             maxFileCount="10"
                             maxFileCountMessage="Limited to 10 files uploaded concurrently."
                             fileEntryListener="#{userManager.user.uploadListener}"
                             maxFileSize="6291456"
                             maxFileSizeMessage="Submitted file is too large."
                             maxTotalSize="18874368"
                             maxTotalSizeMessage="Total size of submitted files is too large."
                             required="true"
                             requiredMessage="The file is required to submit this form."
                             useOriginalFilename="true"
                             absolutePath="/awesome-dates/userPictures/temp/"
                             autoUpload="false"
                             multiple="true"
                             />
              <ace:messages id="msgs" for="uploadForm:file-entry"/>
            </h:form>


          </ace:panel>
        </ace:panel>

      </ui:define>
    </ui:composition>
  </h:body>
</html>

